<template>
    <div>
        <div class=" header">
            <div>
                <img :src="userSource.head_img">
                <div v-if="!!userSource.vip_level">
                    <img
                        v-if="userSource.vip_level =='1'"
                        src="../../asset/icon/icon_mine_vip1.png"
                    >
                    <img
                        v-if="userSource.vip_level =='2'"
                        src="../../asset/icon/icon_mine_vip2.png"
                    >
                    <span>{{userSource.vip_name}}</span>
                </div>
            </div>
            <span>{{userSource.user_nickname}}</span>
            <router-link
                :to="{path:'/member',query:{vip_level: userSource.vip_level}}"
                v-if="!userSource.vip_level!==2"
            >
                <img src="../../asset/icon/icon_mine_member.png">
                <span>成为合伙人</span>
            </router-link>
        </div>
        <div class="titile">
            <div>
                <span>余额:</span>
                <span>￥{{userSource.money == null?0:userSource.money}}</span>
            </div>
            <div>
                <router-link to="/money/income">明细</router-link>
                <router-link :to="{path:'/drawMoney',query:{commision: userSource.money ,is_real_name:userSource.is_real_name}}">提现</router-link>

            </div>
        </div>
        <yd-cell-group>
            <yd-cell-item
                arrow
                type="link"
                :href="item.route"
                v-for="(item, index) in cellList"
                :key="index"
                v-show="item.show"
                class="list"
            >
                <span slot="left">{{item.title}}</span>
            </yd-cell-item>
        </yd-cell-group>
        <div style="height:50px;"></div>
        <Footer :idx="3" />
    </div>
</template>
<script>
import Footer from '../../component/Footer'
export default {
    name: "mine",
    data() {
        return {
            userSource: {},
            cellList: [
                { title: '我的优惠券', route: '/order/orderAll', show: true },
                { title: '邀请好友', route: '/friend', show: true },
                { title: '我的邀请', route: '/Invitation/InvitationOrdinary', show: true },
            ]
        };
    },
    methods: {
        // 方法
        getUserInfo() {
            let params = {
                member_id: localStorage.getItem('token'),
            };
            this.$post("/member/get_info", params)
                .then(res => {
                    if (res.code === 20000) {
                        this.userSource = res.data
                    }
                })
                .catch(err => { });

        }
    },
    beforeCreate() {
        document.querySelector("body").setAttribute("style", "background-color:#e1deff");
    },
    created() {
        // 实例创建完成
        this.getUserInfo()
    },
    components: {
        'Footer': Footer,
    },
};
</script>
<style lang="less" scoped>
@import url("../../asset/css/mine");
</style>